package org.seven.jrdp.biz.t.service;

import java.util.List;

import org.seven.jrdp.biz.t.mapper.TJhMapper;
import org.seven.jrdp.biz.t.model.TJh;
import org.seven.jrdp.commons.model.Option;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

@Service
public class TJhService {
	@Autowired
	private TJhMapper tJhMapper;

	@Transactional(readOnly = true)
	public List<TJh> find() {
		Example example = new Example(TJh.class);
		example.orderBy("mc");
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("deleteFlag", "0");
		return tJhMapper.selectByExample(example);
	}

	@Transactional(readOnly = true)
	public TJh get(String id) {
		return tJhMapper.selectByPrimaryKey(id);
	}

	@Transactional
	public void insert(TJh tJh) {
		tJhMapper.insertSelective(tJh);
	}

	@Transactional
	public void update(TJh tJh) {
		tJhMapper.updateByPrimaryKeySelective(tJh);
	}

	@Transactional
	public void delete(String id) {
		TJh tJh = new TJh();
		tJh.setId(id);
		tJh.setDeleteFlag("1");
		tJhMapper.updateByPrimaryKeySelective(tJh);
	}

	@Transactional(readOnly = true)
	public List<Option> getOption() {
		return tJhMapper.getOption();
	}
}